﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AMS.DD35.Common.State
{
    public class StateManager : IStateManager
    {
        public object SessionVariable
        {
            get { return HttpContext.Current.Session["sessionVariable"]; }
            set { HttpContext.Current.Session["sessionVariable"] = value; }
        }

        public string UserName
        {
            get { return HttpContext.Current.Session["userName"] as string ?? String.Empty; }
            set { HttpContext.Current.Session["userName"] = value; }
        }

        public long CharacterID
        {
            get
            {
                object o = HttpContext.Current.Session["characterID"];
                if (o == null)
                    return -1;
                return Convert.ToInt64(o);
            }
            set { HttpContext.Current.Session["characterID"] = value; }
        }

        public object Get(string index)
        {
            return HttpContext.Current.Session[index];
        }

        public void Set(string index, object o)
        {
            HttpContext.Current.Session[index] = o;
        }
    }
}